package com.atguigu.f_bigdecimal;

import java.math.BigDecimal;

public class Demo {
    public static void main(String[] args) {
        System.out.println(0.1 * 0.2);

        //创建2个BigDecimal对象
//        BigDecimal bd1 = new BigDecimal(0.1);
//        BigDecimal bd2 = new BigDecimal(0.2);
        BigDecimal bd1 = new BigDecimal("0.1");//
        BigDecimal bd2 = new BigDecimal("0.2");//

        System.out.println("bd1.add(bd2) = " + bd1.add(bd2));//加法 0.3
        System.out.println("bd1.subtract(bd2) = " + bd1.subtract(bd2));//减法 -0.1
        System.out.println("bd1.multiply(bd2) = " + bd1.multiply(bd2));//乘法 0.02
        System.out.println("bd1.divide(bd2) = " + bd1.divide(bd2));//除法 0.5
    }
}
